package com.cms.common.aop.actionLog;


import com.cms.common.model.services.ActionLogService;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;


@Aspect
@Component
@Slf4j
public class ActionLogAspect {

    @Autowired
    ActionLogService actionLogService;

    //定义了切面的处理逻辑。即方法上加了@PermissionCheck
    @After("@annotation(com.cms.common.aop.actionLog.ActionLogTaget)")
    public void after(JoinPoint pjp) throws Throwable {
        log.info("====================开始记录操作日志============================");
        //1.记录日志信息
        Signature signature = pjp.getSignature();
        //2.角色权限校验
        MethodSignature methodSignature = (MethodSignature) signature;
        Method targetMethod = methodSignature.getMethod();
        if (targetMethod.isAnnotationPresent(ActionLogTaget.class)) {


        }
    }
}
